package com.viknix.threadpool.manager.cluster.lookup;

import com.viknix.threadpool.manager.cluster.core.Member;
import com.viknix.threadpool.manager.cluster.core.ServerMemberManager;
import com.viknix.threadpool.manager.server.dependence.exception.ServerProcessException;

import java.util.Collection;
import java.util.concurrent.atomic.AtomicBoolean;

/**
 * @Author: Dongqi
 * @Date: 2021/11/10 19:19
 * @Version 1.0
 * @Description: 寻址模式基类
 */
public abstract class AbstractMemberLookup implements MemberLookup {

    protected ServerMemberManager memberManager;

    protected AtomicBoolean start = new AtomicBoolean(false);

    /**
     * 注入 memberManager
     *
     * @param memberManager {@link ServerMemberManager}
     */
    @Override
    public void injectMemberManager(ServerMemberManager memberManager) {
        this.memberManager = memberManager;
    }

    @Override
    public void afterLookup(Collection<Member> members) {
        this.memberManager.memberChange(members);
    }

    @Override
    public void destroy() throws ServerProcessException {

    }
}
